package com.day1020;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class FlyFrame extends JFrame {
    FlyPanel flyPanel = new FlyPanel();
    public static final int WIDTH = 400;
    public static final int HEIGHT = 600;
    public FlyFrame() {
        //  设置窗体大小
        super.setSize(WIDTH, HEIGHT);
        //  设置一直在最上面
        super.setAlwaysOnTop(true);
        //  设置窗体居中
        super.setLocationRelativeTo(null);
        //   设置游戏小图标
        BufferedImage bufferedImage = null;
        try {
            bufferedImage = ImageIO.read(new File("src\\main\\java\\com\\day1020\\imgs\\icon72x72.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        super.setIconImage(bufferedImage);
        //  设置游戏标题
        super.setTitle("飞机大战");
        //  设置窗体关闭，退出游戏
        super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        super.add(flyPanel);
        //  设置窗体不可更改大小
        super.setResizable(false);
        super.setVisible(true);
    }
}
